package com.xiaochong.tir.apiservice.component.hbase;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xc.logclient.utils.LogTrace;
import com.xiaochong.tir.apiservice.component.HbaseBaseQueryComponent;
import com.xiaochong.tir.apiservice.component.RedisCacheComponent;
import com.xiaochong.tir.apiservice.config.hbase.HbaseConnectionFactory;
import com.xiaochong.service.common.config.redis.RedisServer;
import com.xiaochong.tir.apiservice.service.CurrencyIndustryCategoryService;
import com.xiaochong.tir.common.data.hbasepo.*;
import com.xiaochong.tir.common.data.po.ConceptCategory;
import com.xiaochong.tir.common.data.po.CurrencyIndustryCategory;
import com.xiaochong.tir.common.data.po.CurrencyInfo;
import com.xiaochong.tir.common.exception.hbase.HbaseCloseExcetion;
import com.xiaochong.tir.common.exception.hbase.HbaseConnectionExcetion;
import com.xiaochong.tir.common.exception.hbase.HbaseGetTableExcetion;
import com.xiaochong.tir.common.exception.hbase.HbaseTablePutExcetion;
import com.xiaochong.tir.common.util.CollectionUtil;
import com.xiaochong.tir.common.util.DateUtils;
import com.xiaochong.tir.common.util.HbaseTableUtils;
import com.xiaochong.tir.common.util.RedisKeysUtils;

import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.util.Bytes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;


/**
 * Created by cx on 2018/4/25.
 */
@Component
public class CurrencyInfoHbaseComponent {

    @Autowired
    private HbaseConnectionFactory hbaseConnectionFactory;

    @Autowired
    private HbaseBaseQueryComponent hbaseBaseQueryComponent;

    @Autowired
    private RedisServer redisServer;

    @Autowired
    private CurrencyIndustryCategoryService currencyIndustryCategoryService;

    @Resource
    private RedisCacheComponent redisCacheComponent;

    /**
     * 示例
     */
    public void test(){
        try {

            Connection connection = hbaseConnectionFactory.getConnection();
            Table table =  hbaseConnectionFactory.getTable( connection, HbaseTableUtils.CURRENCY_INFO_TABLE_NAME);
            Put put = new Put("20180428".getBytes());
            put.addColumn(HbaseTableUtils.CURRENCY_INFO_TABLE_FAMILY.getBytes(),"qualifier".getBytes(),new JSONObject().toJSONString().getBytes());
            hbaseConnectionFactory.tablePut(table,put);
            hbaseConnectionFactory.closeAll(connection,table);


        } catch (HbaseConnectionExcetion hbaseConnectionExcetion) {
            hbaseConnectionExcetion.printStackTrace();
        }  catch (HbaseGetTableExcetion hbaseGetTableExcetion) {
            hbaseGetTableExcetion.printStackTrace();
        } catch (HbaseTablePutExcetion hbaseTablePutExcetion) {
            hbaseTablePutExcetion.printStackTrace();
        } catch (HbaseCloseExcetion hbaseCloseExcetion) {
            hbaseCloseExcetion.printStackTrace();
        }
    }



    /**
     * 插入hbase数据
     *
     * @param tableName
     * @param rowKey
     * @param family
     * @param qualifier
     * @param value
     */
    public void insertHbaseString(String tableName, String rowKey, String family, String key, String value){
        try {
            Connection connection = hbaseConnectionFactory.getConnection();
            Table table =  hbaseConnectionFactory.getTable( connection, tableName);
            Put put = new Put(rowKey.getBytes());
            put.addColumn(Bytes.toBytes(family),
                    Bytes.toBytes(key),
                    Bytes.toBytes(value));
            hbaseConnectionFactory.tablePut(table,put);
            hbaseConnectionFactory.closeAll(connection,table);

        } catch (HbaseConnectionExcetion | HbaseGetTableExcetion | HbaseCloseExcetion | HbaseTablePutExcetion e) {
            LogTrace.error(e.getMessage(), e);
        }
    }


    /**
     * 插入hbase数据
     *
     * @param tableName
     * @param rowKey
     * @param family
     * @param object
     */
    public void insertHbaseObject(String tableName, String rowKey, String family,Object object) {
        try {
            Connection connection = hbaseConnectionFactory.getConnection();
            Table table =  hbaseConnectionFactory.getTable( connection, tableName);
            Put put = new Put(rowKey.getBytes());
            JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(object));
            Map<String, Object> map = jsonObject.getInnerMap();
            for(Map.Entry<String, Object> entry: map.entrySet()){
                String key = entry.getKey();
                put.addColumn(Bytes.toBytes(family),
                        Bytes.toBytes(key),
                        Bytes.toBytes(entry.getValue()!=null?entry.getValue().toString():"") );
            }
            hbaseConnectionFactory.tablePut(table,put);
            hbaseConnectionFactory.closeAll(connection,table);
        } catch (HbaseCloseExcetion | HbaseGetTableExcetion | HbaseTablePutExcetion | HbaseConnectionExcetion e) {
            e.printStackTrace();
            LogTrace.error(e.getMessage(),e);
        }
    }



    /**
     * hbase批量插入数据
     *
     * @param tableName
     * @param rowKey
     * @param family
     * @param list
     */
    public void insertHbaseList(String tableName, String rowKey, String family,List list) {
        try {
            Connection connection = hbaseConnectionFactory.getConnection();
            Table table =  hbaseConnectionFactory.getTable( connection, tableName);
            List<Put> putList = new ArrayList<>();
            for (int i = 0; i < list.size(); i++) {
                Put put = new Put(rowKey.getBytes());//row kye
                JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(list.get(i)));
                Map<String, Object> map = jsonObject.getInnerMap();
                for(Map.Entry<String, Object> entry: map.entrySet()){
                    String key = entry.getKey();
                    put.addColumn(Bytes.toBytes(family),
                            Bytes.toBytes(key),
                            Bytes.toBytes(entry.getValue()!=null?entry.getValue().toString():"") );
                }

                putList.add(put);
            }
            hbaseConnectionFactory.tablePut(table,putList);
            hbaseConnectionFactory.closeAll(connection,table);
        } catch (HbaseCloseExcetion | HbaseGetTableExcetion | HbaseTablePutExcetion | HbaseConnectionExcetion e) {
            e.printStackTrace();
            LogTrace.error(e.getMessage(),e);
        }
    }


    /**
     * 将大盘指数存入hbase
     *
     * @param broaderIndex
     */
    public void insertHbaseBroaderIndex(BroaderIndex broaderIndex) {
        if(broaderIndex==null){
            return;
        }
        try {
            String data = hbaseBaseQueryComponent.selectByQualifierData(HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_NAME
                    , HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_FAMILY
                    , HbaseTableUtils.EVERY_DAY_BROADER_INDEX_QUALIFIER
                    , DateUtils.getCurrentDateString()
                    );
            JSONArray jsonArray;
            if(StringUtils.isBlank(data)){
                jsonArray = new JSONArray();
            }else{
                jsonArray = JSON.parseArray(data);
            }
            jsonArray.add(broaderIndex);
            this.insertHbaseString(HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_NAME
                    ,DateUtils.getCurrentDateString()
                    ,HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_FAMILY
                    ,HbaseTableUtils.EVERY_DAY_BROADER_INDEX_QUALIFIER
                    ,jsonArray.toJSONString());
        } catch (HbaseConnectionExcetion | HbaseGetTableExcetion | IOException | HbaseCloseExcetion e) {
            e.printStackTrace();
            LogTrace.error(e.getMessage(),e);
        }

    }


    /**
     * 获取大盘指数
     *
     * @return
     */
    public BroaderIndex getLastBroaderIndex(){
        BroaderIndex broaderIndex =null;
        try {
            Date thisDate = new Date();
            Date minCreateTime = redisCacheComponent.getCurrencyInfoHbaseMinCreateTime();

            String data = null;
            while (thisDate.getTime()>minCreateTime.getTime() && StringUtils.isBlank(data)){
                data = hbaseBaseQueryComponent.selectByQualifierData(HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_NAME
                        , HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_FAMILY
                        , HbaseTableUtils.EVERY_DAY_BROADER_INDEX_QUALIFIER
                        , DateUtils.dateFormatString(thisDate,DateUtils.format_ymds)
                );
                LocalDateTime dateTime = DateUtils.dateToLocalDateTime(thisDate);
                dateTime = dateTime.minusDays(1);
                thisDate = DateUtils.localDateTimeToDate(dateTime);

            }

            JSONArray jsonArray;
            if(StringUtils.isBlank(data)){
                return null;
            }
            jsonArray = JSON.parseArray(data);
            if(CollectionUtil.isBlank(jsonArray)){return null;}
            broaderIndex = jsonArray.getObject(jsonArray.size()-1,BroaderIndex.class);
        } catch (HbaseConnectionExcetion | HbaseGetTableExcetion | IOException | HbaseCloseExcetion e) {
            e.printStackTrace();
            LogTrace.error(e.getMessage(),e);
        }
        return broaderIndex;
    }


    /**
     * 获取权重、行业指数
     */
    public CalculateTicker getLastCalculateTicker() {
        CalculateTicker calculateTicker = null;
        try {
            String data = hbaseBaseQueryComponent.selectByQualifierData(HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_NAME
                    , HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_FAMILY
                    , HbaseTableUtils.CALCULATE_TICKER_QUALIFIER
                    , DateUtils.getCurrentDateString());
            if(StringUtils.isBlank(data)){
                return null;
            }else{
                calculateTicker = JSON.parseObject(data, CalculateTicker.class);
            }

        } catch (HbaseConnectionExcetion | HbaseGetTableExcetion | HbaseCloseExcetion | IOException e) {
            e.printStackTrace();
            LogTrace.error(e.getMessage(), e);
        }catch (Exception e){
            e.printStackTrace();
            LogTrace.error(e.getMessage(), e);
        }
        return calculateTicker;
    }
    /**
     * 将权重、行业指数存入hbase
     *
     */
    public void insertHbaseCalculate(WeightIndex weightIndex, List<IndustryIndex> industryIndices) {
        try {
            String data = hbaseBaseQueryComponent.selectByQualifierData(HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_NAME
                    , HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_FAMILY
                    , HbaseTableUtils.CALCULATE_TICKER_QUALIFIER
                    , DateUtils.getCurrentDateString());
            CalculateTicker calculateTicker;
            if(StringUtils.isBlank(data)){
                calculateTicker = new CalculateTicker();
            }else{
//                    calculateTicker = new CalculateTicker();
                calculateTicker = JSON.parseObject(data, CalculateTicker.class);
            }
            List<WeightIndex> weightIndices = calculateTicker.getWeightIndices();
            if(weightIndices==null){
                weightIndices = new ArrayList<>();
            }
            if(weightIndex!=null){
                weightIndices.add(weightIndex);
                calculateTicker.setWeightIndices(weightIndices);
            }

            if(calculateTicker.getIndustryIndices()==null){
                calculateTicker.setIndustryIndices(new HashMap<>());
            }
            if(CollectionUtil.isNotBlank(industryIndices)){
                for (IndustryIndex industryIndex:industryIndices) {
                    List<IndustryIndex> timeIndustryIndices =
                            calculateTicker.getIndustryIndices()
                                    .get(industryIndex.getCurrencyIndustryCategoryId());
                    if(timeIndustryIndices==null){
                        timeIndustryIndices = new ArrayList<>();
                    }
                    timeIndustryIndices.add(industryIndex);
                    calculateTicker.getIndustryIndices()
                            .put(industryIndex.getCurrencyIndustryCategoryId(),timeIndustryIndices);

                }
            }


            this.insertHbaseString(HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_NAME
                    ,DateUtils.getCurrentDateString()
                    ,HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_FAMILY
                    ,HbaseTableUtils.CALCULATE_TICKER_QUALIFIER
                    ,JSON.toJSONString(calculateTicker));


        } catch (HbaseConnectionExcetion | HbaseGetTableExcetion | HbaseCloseExcetion | IOException e) {
            e.printStackTrace();
            LogTrace.error(e.getMessage(), e);
        }catch (Exception e){
            e.printStackTrace();
            LogTrace.error(e.getMessage(), e);
        }
    }

    /**
     * 将权行业指数存入hbase
     *
     * @param calculateTicker
     */
    public void insertHbaseIndustryIndex(List<IndustryIndex> industryIndices) {
        for (IndustryIndex industryIndex:industryIndices) {
            try {
                Date createTime = industryIndex.getCreateTime();

                String data = hbaseBaseQueryComponent.selectByQualifierData(HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_NAME
                        , HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_FAMILY
                        , HbaseTableUtils.CALCULATE_TICKER_QUALIFIER
                        , industryIndex.getCurrencyIndustryCategoryId()+"@"
                                +DateUtils.dateFormatString(createTime,DateUtils.format_ymds));
                /*JSONObject mainObject;
                if(StringUtils.isBlank(data)){
                    mainObject = new JSONObject();
                }else{
                    mainObject = JSON.parseObject(data);
                }
                mainObject.put(industryIndex.getCurrencyIndustryCategoryId()+"@"
                                +DateUtils.dateToLocalDateTime(industryIndex.getCreateTime()).getHour()
                        ,industryIndex);*/
                JSONArray jsonArray ;
                if(StringUtils.isBlank(data)){
                    jsonArray = new JSONArray();
                }else{
                    jsonArray = JSON.parseArray(data);
                }
                jsonArray.add(industryIndex);

                this.insertHbaseString(HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_NAME
                        ,industryIndex.getCurrencyIndustryCategoryId()+"@"
                                +DateUtils.dateFormatString(createTime,DateUtils.format_ymds)
                        ,HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_FAMILY
                        ,HbaseTableUtils.CALCULATE_TICKER_QUALIFIER
                        ,jsonArray.toJSONString());


            } catch (HbaseConnectionExcetion | HbaseGetTableExcetion | HbaseCloseExcetion | IOException e) {
                e.printStackTrace();
                LogTrace.error(e.getMessage(), e);
            }catch (Exception e){
                e.printStackTrace();
                LogTrace.error(e.getMessage(), e);
            }
        }

    }


    /**
     * 获取最新行业指数
     * @return
     */
    public List<IndustryIndex> getLastIndustryIndex() {

        List<IndustryIndex> returnList = new ArrayList<>();

        List<CurrencyIndustryCategory> currencyIndustryCategories
                = currencyIndustryCategoryService.selectByEntityList(new CurrencyIndustryCategory());

        for (CurrencyIndustryCategory currencyIndustryCategory:currencyIndustryCategories) {
            try {
                Date thisDate = new Date();
                Date minCreateTime = redisCacheComponent.getCurrencyInfoHbaseMinCreateTime();

                String data = null;
                while (thisDate.getTime()>minCreateTime.getTime() && StringUtils.isBlank(data)){
                    data = hbaseBaseQueryComponent.selectByQualifierData(HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_NAME
                            , HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_FAMILY
                            , HbaseTableUtils.CALCULATE_TICKER_QUALIFIER
                            , currencyIndustryCategory.getId() + "@" + DateUtils.dateFormatString(thisDate,DateUtils.format_ymds)
                    );
                    LocalDateTime dateTime = DateUtils.dateToLocalDateTime(thisDate);
                    dateTime = dateTime.minusDays(1);
                    thisDate = DateUtils.localDateTimeToDate(dateTime);

                }



                JSONArray jsonArray = JSON.parseArray(data);
                if(CollectionUtil.isNotBlank(jsonArray)){
                    returnList.add(jsonArray.getObject(jsonArray.size()-1,IndustryIndex.class));
                }


            } catch (HbaseConnectionExcetion | HbaseGetTableExcetion | HbaseCloseExcetion | IOException e) {
                e.printStackTrace();
                LogTrace.error(e.getMessage(), e);
            }catch (Exception e){
                e.printStackTrace();
                LogTrace.error(e.getMessage(), e);
            }
        }
        return returnList;

    }


    /**
     * 将权重指数存入hbase
     *
     */
    public void insertHbaseWeightIndex(WeightIndex weightIndex) {
        try {
            String data = hbaseBaseQueryComponent.selectByQualifierData(HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_NAME
                    , HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_FAMILY
                    , HbaseTableUtils.CALCULATE_TICKER_QUALIFIER
                    , HbaseTableUtils.HOME_INDEX_EVERY_DAY_WEIGHTINDEX_ROWKEY+DateUtils.getCurrentDateString());
            /*JSONObject mainObject;
            if(StringUtils.isBlank(data)){
                mainObject = new JSONObject();
            }else{
                mainObject = JSON.parseObject(data);
            }
            if(weightIndex!=null){
                mainObject.put(
                        DateUtils.dateToLocalDateTime(weightIndex.getCreateTime()).getHour()+"",weightIndex);
            }

            this.insertHbaseString(HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_NAME
                    ,HbaseTableUtils.HOME_INDEX_EVERY_DAY_WEIGHTINDEX_ROWKEY+DateUtils.getCurrentDateString()
                    ,HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_FAMILY
                    ,HbaseTableUtils.CALCULATE_TICKER_QUALIFIER
                    ,mainObject.toJSONString());*/
            JSONArray jsonArray ;
            Map<String, String> map = new HashMap<String, String>();
            if(StringUtils.isBlank(data)){
                jsonArray = new JSONArray();
                //当天第一条数据，最新权重指数信息直接存入缓存
                map.put("index", weightIndex.getWeightIndex() + "");
                map.put("rise", weightIndex.getWeightRiseFall() + "");
                map.put("highindex", weightIndex.getWeightIndex() + "");
                map.put("lowindex", weightIndex.getWeightIndex() + "");
            }else{
                jsonArray = JSON.parseArray(data);
                //非当天第一条数据，对比选出高开权重指数和低收权重指数
                String result = redisServer.get(RedisKeysUtils.TIR_LAST_WEIGHT_INDEX);
                if(result != null && !"".equals(result.trim())){
                	map = JSON.parseObject(result, Map.class);
                    BigDecimal bighigh = new BigDecimal(map.get("highindex"));
                    BigDecimal biglow = new BigDecimal(map.get("lowindex"));
                    if(bighigh.compareTo(weightIndex.getWeightIndex()) == -1){
                    	map.put("highindex", weightIndex.getWeightIndex() + "");
                    }else if(biglow.compareTo(weightIndex.getWeightIndex()) == 1){
                    	map.put("lowindex", weightIndex.getWeightIndex() + "");
                    }
                }else{
                	setWightIndexLastInfo(map, jsonArray);
                }
                map.put("rise", weightIndex.getWeightRiseFall() + "");
                map.put("index", weightIndex.getWeightIndex() + "");
            }
            //最新权重指数入库前先清除以前的数据
            redisServer.remove(RedisKeysUtils.TIR_LAST_WEIGHT_INDEX);
            //最新权重指数信息存入缓存
            redisServer.set(RedisKeysUtils.TIR_LAST_WEIGHT_INDEX, JSON.toJSONString(map));
            jsonArray.add(weightIndex);

            this.insertHbaseString(HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_NAME
                    ,HbaseTableUtils.HOME_INDEX_EVERY_DAY_WEIGHTINDEX_ROWKEY+DateUtils.getCurrentDateString()
                    ,HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_FAMILY
                    ,HbaseTableUtils.CALCULATE_TICKER_QUALIFIER
                    ,jsonArray.toJSONString());

        } catch (HbaseConnectionExcetion | HbaseGetTableExcetion | HbaseCloseExcetion | IOException e) {
            e.printStackTrace();
            LogTrace.error(e.getMessage(), e);
        }catch (Exception e){
            e.printStackTrace();
            LogTrace.error(e.getMessage(), e);
        }
    }
    
    /**
     * 最新权重信息缓存为空时，需要筛选Hbase数据加入缓存
     */
    public void setWightIndexLastInfo(Map<String, String> map, JSONArray jsonArray){
    	//获取收盘权重指数
		JSONObject objwe = (JSONObject)jsonArray.get(jsonArray.size() - 1);
		WeightIndex we = objwe.toJavaObject(WeightIndex.class);
		//初始化高开权重指数和低收权重指数
		BigDecimal highopen = we.getWeightIndex();
		BigDecimal lowclose = we.getWeightIndex();
		for(int i = 0; i < jsonArray.size(); i++){
			JSONObject obj = (JSONObject)jsonArray.get(i);
			WeightIndex w = obj.toJavaObject(WeightIndex.class);
			BigDecimal big = w.getWeightIndex();
			if(big.compareTo(lowclose) == -1){
				//获取最小权重指数
				lowclose = big;
			}else if(big.compareTo(highopen) == 1){
				//获取最大权重指数
				highopen = big;
			}
		}
        map.put("highindex", highopen + "");
        map.put("lowindex", lowclose + "");
    }


    /**
     * 获取最新权重指数
     *
     * @return
     */
    public WeightIndex getLastWeightIndex() {
        try {
            Date thisDate = new Date();
            Date minCreateTime = redisCacheComponent.getCurrencyInfoHbaseMinCreateTime();

            String data = null;
            while (thisDate.getTime()>minCreateTime.getTime() && StringUtils.isBlank(data)){
                data = hbaseBaseQueryComponent.selectByQualifierData(HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_NAME
                        , HbaseTableUtils.HOME_INDEX_EVERY_DAY_RECORDING_TABLE_FAMILY
                        , HbaseTableUtils.CALCULATE_TICKER_QUALIFIER
                        , HbaseTableUtils.HOME_INDEX_EVERY_DAY_WEIGHTINDEX_ROWKEY + DateUtils.dateFormatString(thisDate,DateUtils.format_ymds)
                );
                LocalDateTime dateTime = DateUtils.dateToLocalDateTime(thisDate);
                dateTime = dateTime.minusDays(1);
                thisDate = DateUtils.localDateTimeToDate(dateTime);

            }
            JSONArray jsonArray = JSON.parseArray(data);
            if(CollectionUtil.isBlank(jsonArray)){return null;}
            return jsonArray.getObject(jsonArray.size()-1,WeightIndex.class);

        } catch (HbaseConnectionExcetion | HbaseGetTableExcetion | HbaseCloseExcetion | IOException e) {
            e.printStackTrace();
            LogTrace.error(e.getMessage(), e);
        }catch (Exception e){
            e.printStackTrace();
            LogTrace.error(e.getMessage(), e);
        }
        return null;
    }

    /**
     * 保存量能变化
     *
     * @param diagnosisQuantumEnergies
     */
    public void saveDiagnosisQuantumEnergy(List<DiagnosisQuantumEnergy> diagnosisQuantumEnergies) {
        for (DiagnosisQuantumEnergy quantumEnergy:diagnosisQuantumEnergies) {
            try {
                Date createTime = quantumEnergy.getCreateTime();
                LocalDateTime dateTime = DateUtils.dateToLocalDateTime(createTime);
                String data = hbaseBaseQueryComponent.selectByQualifierData(HbaseTableUtils.CURRENCY_DIAGNOSIS_QUANTUM_ENERGY_INFO_TABLE_NAME
                        , HbaseTableUtils.CURRENCY_DIAGNOSIS_QUANTUM_ENERGY_INFO_TABLE_FAMILY
                        , HbaseTableUtils.CURRENCY_DIAGNOSIS_QUANTUM_ENERGY_INFO_QUALIFIE
                        , quantumEnergy.getId()+"@"+DateUtils.dateFormatString(
                                createTime,DateUtils.format_ymds
                        ));
                JSONObject mainObject;
                if(StringUtils.isBlank(data)){
                    mainObject = new JSONObject();
                }else{
                    mainObject = JSON.parseObject(data);
                }
                String key = dateTime.getHour()+"";
                JSONArray jsonArray = mainObject.getJSONArray(key);
                if(jsonArray==null){
                    jsonArray = new JSONArray();
                }
                jsonArray.add(quantumEnergy);
                mainObject.put(key,jsonArray);
                this.insertHbaseString(HbaseTableUtils.CURRENCY_DIAGNOSIS_QUANTUM_ENERGY_INFO_TABLE_NAME
                        ,quantumEnergy.getId()+"@"+DateUtils.dateFormatString(
                                createTime,DateUtils.format_ymds)
                        ,HbaseTableUtils.CURRENCY_DIAGNOSIS_QUANTUM_ENERGY_INFO_TABLE_FAMILY
                        ,HbaseTableUtils.CURRENCY_DIAGNOSIS_QUANTUM_ENERGY_INFO_QUALIFIE
                        ,mainObject.toJSONString());
            } catch (HbaseConnectionExcetion | HbaseCloseExcetion | IOException | HbaseGetTableExcetion e) {
                e.printStackTrace();
                LogTrace.error(e.getMessage(),e);
            }
        }



    }

    /**
     * 获取最新量能变化
     *
     * @return
     */
    public List<DiagnosisQuantumEnergy> getLastDiagnosisQuantumEnergy() {
        List<DiagnosisQuantumEnergy> quantumEnergies = new ArrayList<>();
        List<CurrencyInfo> currencyInfos = redisCacheComponent.getDiagnosisCurrencyList();
        if(CollectionUtil.isBlank(currencyInfos)){
            return null;
        }
        for (CurrencyInfo currencyInfo:currencyInfos) {
            try {

                Date thisDate = new Date();
                Date minCreateTime = redisCacheComponent.getCurrencyInfoHbaseMinCreateTime();

                String data = null;
                JSONObject mainObject = null;
                while (thisDate.getTime()>minCreateTime.getTime() && CollectionUtil.isBlank(mainObject)){
                    data = hbaseBaseQueryComponent.selectByQualifierData(HbaseTableUtils.CURRENCY_DIAGNOSIS_QUANTUM_ENERGY_INFO_TABLE_NAME
                            , HbaseTableUtils.CURRENCY_DIAGNOSIS_QUANTUM_ENERGY_INFO_TABLE_FAMILY
                            , HbaseTableUtils.CURRENCY_DIAGNOSIS_QUANTUM_ENERGY_INFO_QUALIFIE
                            , currencyInfo.getCmcId() + "@" + DateUtils.dateFormatString(thisDate,DateUtils.format_ymds)
                    );
                    if(StringUtils.isNotBlank(data)){
                        mainObject = JSON.parseObject(data);
                    }
                    LocalDateTime dateTime = DateUtils.dateToLocalDateTime(thisDate);
                    dateTime = dateTime.minusDays(1);
                    thisDate = DateUtils.localDateTimeToDate(dateTime);

                }
                if(CollectionUtil.isBlank(mainObject)){
                   return null;
                }
                for (int i = 0; i < LocalDateTime.now().getHour(); i++) {
                    String key = String.valueOf(i);
                    JSONArray jsonArray = mainObject.getJSONArray(key);
                    if(CollectionUtil.isBlank(jsonArray)){
                        continue;
                    }
                    quantumEnergies.add(jsonArray.getObject(jsonArray.size()-1,DiagnosisQuantumEnergy.class));
                    break;
                }

            } catch (HbaseConnectionExcetion | HbaseCloseExcetion | IOException | HbaseGetTableExcetion e) {
                e.printStackTrace();
                LogTrace.error(e.getMessage(),e);
            }
        }
        return quantumEnergies;
    }


    /**
     * 获取最新市场热度
     * @return
     */
    public TrendsInfo getLaseGoogleTrendsByCurrencyInfo(String cmcId) {
        TrendsInfo trendsInfo = null;
        try{
            //redisServer.set(RedisKeysUtils.CURRENCYINFO_HBASE_MIN_CREATETIME,date.getTime());
            Date thisDate = new Date();
            Date minCreateTime = redisCacheComponent.getCurrencyInfoHbaseMinCreateTime();

            String data = null;
            while (thisDate.getTime()>minCreateTime.getTime()){

                data = hbaseBaseQueryComponent.selectByQualifierData(HbaseTableUtils.DAILY_MARKET_HEAT_TABLE_NAME
                        , HbaseTableUtils.MARKET_HEAT_TABLE_NAME_FAMILY
                        , HbaseTableUtils.MARKET_HEAT_TABLE_NAME_QUALIFIER
                        , cmcId + "@" + DateUtils.dateFormatString(thisDate,DateUtils.format_ymds)
                );
                JSONObject mainObject = JSON.parseObject(data);
                LocalDateTime dateTime = DateUtils.dateToLocalDateTime(thisDate);
                dateTime = dateTime.minusDays(1);
                thisDate = DateUtils.localDateTimeToDate(dateTime);
                if(CollectionUtil.isBlank(mainObject)){continue;}

                for (int i = 0; i < LocalDateTime.now().getHour(); i++) {
                    String key = String.valueOf(i);
                    JSONArray jsonArray = mainObject.getJSONArray(key);
                    if(CollectionUtil.isNotBlank(jsonArray)){
                        trendsInfo = jsonArray.getObject(jsonArray.size()-1,TrendsInfo.class);
                    }
                    if(trendsInfo!=null){
                        return trendsInfo;
                    }
                }

            }

        } catch (Exception e) {
            e.printStackTrace();
            LogTrace.error(e.getMessage(),e);
        }
        return trendsInfo;
    }

    /**
     * 获取最新市场热度
     * @return
     */
    public List<TrendsInfo> getLaseGoogleTrends() {
        List<TrendsInfo> trendsInfos = new ArrayList<>();
        List<CurrencyInfo> currencyInfos = redisCacheComponent.getDiagnosisCurrencyList();
        if(CollectionUtil.isBlank(currencyInfos)){
            return null;
        }
        for (CurrencyInfo currencyInfo:currencyInfos) {
            TrendsInfo trends = this.getLaseGoogleTrendsByCurrencyInfo(currencyInfo.getCmcId());
            if(trends!=null){
                trendsInfos.add(trends);
            }
        }
        return trendsInfos;

    }


    /**
     * 获取最新流动性
     * @return
     */
    public List<Liquidity> getLastLiquidity() {
        List<CurrencyInfo> currencyList = redisCacheComponent.getDiagnosisCurrencyList();
        if(CollectionUtil.isBlank(currencyList)){
            return null;
        }
        List<Liquidity> liquidityList = new ArrayList<>();
        for (CurrencyInfo currencyInfo:currencyList) {
            try {
                Date thisDate = new Date();
                Date minCreateTime = redisCacheComponent.getCurrencyInfoHbaseMinCreateTime();

                String data = null;
                while (thisDate.getTime()>minCreateTime.getTime() && StringUtils.isBlank(data)){
                    data = hbaseBaseQueryComponent.selectByQualifierData(HbaseTableUtils.CURRENCY_LIQUIDITY_INFO_TABLE_NAME
                            , HbaseTableUtils.CURRENCY_LIQUIDITY_INFO_TABLE_FAMILY
                            , HbaseTableUtils.CURRENCY_LIQUIDITY_INFO_QUALIFIER
                            , currencyInfo.getCmcId() + "@" + DateUtils.dateFormatString(thisDate,DateUtils.format_ymds)
                    );
                    LocalDateTime dateTime = DateUtils.dateToLocalDateTime(thisDate);
                    dateTime = dateTime.minusDays(1);
                    thisDate = DateUtils.localDateTimeToDate(dateTime);

                }

                JSONObject mainObject;
                if(StringUtils.isBlank(data)){
                    continue;
                }else{
                    mainObject = JSON.parseObject(data);
                }
                for (int i = 0; i < LocalDateTime.now().getHour(); i++) {
                    String key = String.valueOf(i);
                    JSONArray jsonArray = mainObject.getJSONArray(key);
                    Liquidity liquidity = null;
                    if(CollectionUtil.isNotBlank(jsonArray)){
                        liquidity = jsonArray.getObject(jsonArray.size()-1,Liquidity.class);
                    }
                    if(liquidity!=null){
                        liquidityList.add(liquidity);
                        break;
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
                LogTrace.error(e.getMessage(),e);
            }
        }
        return liquidityList;

    }


    /**
     * 保存流动性
     * @param liquidities
     */
    public void saveLiquidity(List<Liquidity> liquidities) {
        for (Liquidity liquidity:liquidities) {
            try {
                String data = hbaseBaseQueryComponent.selectByQualifierData(HbaseTableUtils.CURRENCY_LIQUIDITY_INFO_TABLE_NAME
                        , HbaseTableUtils.CURRENCY_LIQUIDITY_INFO_TABLE_FAMILY
                        , HbaseTableUtils.CURRENCY_LIQUIDITY_INFO_QUALIFIER
                        , liquidity.getId()+"@"+DateUtils.getCurrentDateString());
                JSONObject mainObject;
                if(StringUtils.isBlank(data)){
                    mainObject = new JSONObject();
                }else{
                    mainObject = JSON.parseObject(data);
                }
                String key = LocalDateTime.now().getHour()+"";
                JSONArray jsonArray = mainObject.getJSONArray(key);
                if(jsonArray==null){
                    jsonArray = new JSONArray();
                }
                jsonArray.add(liquidity);
                mainObject.put(key,jsonArray);
                this.insertHbaseString(HbaseTableUtils.CURRENCY_LIQUIDITY_INFO_TABLE_NAME
                        ,liquidity.getId()+"@"+DateUtils.getCurrentDateString()
                        ,HbaseTableUtils.CURRENCY_LIQUIDITY_INFO_TABLE_FAMILY
                        ,HbaseTableUtils.CURRENCY_LIQUIDITY_INFO_QUALIFIER
                        ,mainObject.toJSONString());
            } catch (HbaseConnectionExcetion | HbaseCloseExcetion | IOException | HbaseGetTableExcetion e) {
                e.printStackTrace();
                LogTrace.error(e.getMessage(),e);
            }
        }


    }

    /**
     * 获取前一天最后人气意愿
     * @return
     */
    public Map<String,PopularityIndicator> getYesterdayLastPopularityIndicator() {
        Map<String,PopularityIndicator> indicatorMap = new HashMap<>();
        try{
            String data = hbaseBaseQueryComponent.selectByQualifierData(HbaseTableUtils.POPULARITY_INDICATOR_INFO_TABLE_NAME
                    , HbaseTableUtils.POPULARITY_INDICATOR_INFO_TABLE_FAMILY
                    , HbaseTableUtils.POPULARITY_INDICATOR_INFO_QUALIFIER
                    , DateUtils.getNextDayDateYMD(-1));
            if(StringUtils.isBlank(data)){
                return null;
            }
            JSONObject mainObject = JSON.parseObject(data);
            for (String key:mainObject.keySet()) {
                indicatorMap.put(key,mainObject.getObject(key,PopularityIndicator.class));
            }
        } catch (Exception e) {
            e.printStackTrace();
            LogTrace.error(e.getMessage(),e);
        }

        return indicatorMap;
    }

    /**
     * 获取最新人气意愿
     * @return
     */
    public Map<String,PopularityIndicator> getLastPopularityIndicator() {
        Map<String,PopularityIndicator> indicatorMap = new HashMap<>();
        List<CurrencyInfo> currencyList = redisCacheComponent.getDiagnosisCurrencyList();
        Date minCreateTime = redisCacheComponent.getCurrencyInfoHbaseMinCreateTime();
        for (CurrencyInfo currencyInfo:currencyList) {
            try{
                Date thisDate = new Date();

                String data = null;
                LocalDateTime dateTime = DateUtils.dateToLocalDateTime(thisDate);
                while (thisDate.getTime()>minCreateTime.getTime() && StringUtils.isBlank(data)){
                    data = hbaseBaseQueryComponent.selectByQualifierData(HbaseTableUtils.POPULARITY_INDICATOR_INFO_TABLE_NAME
                            , HbaseTableUtils.POPULARITY_INDICATOR_INFO_TABLE_FAMILY
                            , HbaseTableUtils.POPULARITY_INDICATOR_INFO_QUALIFIER
                            , currencyInfo.getCmcId()+"@"+DateUtils.dateFormatString(thisDate,DateUtils.format_ymds) );
                    dateTime = dateTime.minusHours(1);
                    thisDate = DateUtils.localDateTimeToDate(dateTime);

                }
                if(StringUtils.isBlank(data)){
                    return null;
                }
                JSONObject mainObject = JSON.parseObject(data);
                for (int i = 0; i < 24; i++) {
                    String key = String.valueOf(dateTime.getHour()-1);
                    PopularityIndicator object = mainObject.getObject(key, PopularityIndicator.class);
                    if(object!=null){
                        indicatorMap.put(currencyInfo.getCmcId(),object);
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
                LogTrace.error(e.getMessage(),e);
            }
        }


        return indicatorMap;
    }

    /**
     * 获取最新赚钱效益
     * @return
     */
    public MoneyEffect getLastMoneyEffect() {
        try {
            Date thisDate = new Date();
            Date minCreateTime = redisCacheComponent.getCurrencyInfoHbaseMinCreateTime();

            String data = null;
            while (thisDate.getTime()>minCreateTime.getTime() && StringUtils.isBlank(data)){
                data = hbaseBaseQueryComponent.selectByQualifierData(HbaseTableUtils.DAILY_MONEY_EFFECT_INFO_TABLE_NAME
                        , HbaseTableUtils.DAILY_MONEY_EFFECT_INFO_TABLE_FAMILY
                        , HbaseTableUtils.DAILY_MONEY_EFFECT_INFO_TABLE_QUALIFIER
                        , DateUtils.dateFormatString(thisDate,DateUtils.format_ymds)
                );
                LocalDateTime dateTime = DateUtils.dateToLocalDateTime(thisDate);
                dateTime = dateTime.minusDays(1);
                thisDate = DateUtils.localDateTimeToDate(dateTime);

            }


            JSONObject mainObject;
            if(StringUtils.isBlank(data)){
                return null;
            }else{
                mainObject = JSON.parseObject(data);
            }
            for (int i = 0; i < LocalDateTime.now().getHour(); i++) {
                String key = String.valueOf(i);
                JSONArray jsonArray = mainObject.getJSONArray(key);
                MoneyEffect moneyEffect = null;
                if(CollectionUtil.isNotBlank(jsonArray)){
                    moneyEffect = jsonArray.getObject(jsonArray.size()-1,MoneyEffect.class);
                }
                if(moneyEffect!=null){
                    return moneyEffect;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            LogTrace.error(e.getMessage(),e);
        }
        return null;
    }


    /**
     * 获取最新权重表现
     * @return
     */
    public WeightsPerformance getLastWeightsPerformance() {
        try {
            String data = hbaseBaseQueryComponent.selectByQualifierData(HbaseTableUtils.DAILY_WEIGHT_PERFORMANCE_INFO_TABLE_NAME
                    , HbaseTableUtils.DAILY_WEIGHT_PERFORMANCE_INFO_TABLE_FAMILY
                    , HbaseTableUtils.DAILY_WEIGHT_PERFORMANCE_INFO_TABLE_QUALIFIER
                    , DateUtils.getCurrentDateString());
            JSONObject mainObject;
            if(StringUtils.isBlank(data)){
                return null;
            }else{
                mainObject = JSON.parseObject(data);
            }
            for (int i = 0; i < LocalDateTime.now().getHour(); i++) {
                String key = String.valueOf(i);
                JSONArray jsonArray = mainObject.getJSONArray(key);
                WeightsPerformance weightsPerformance = null;
                if(CollectionUtil.isNotBlank(jsonArray)){
                    weightsPerformance = jsonArray.getObject(jsonArray.size()-1,WeightsPerformance.class);
                }
                if(weightsPerformance!=null){
                    return weightsPerformance;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            LogTrace.error(e.getMessage(),e);
        }
        return null;
    }

    /**
     * 获取最新量能变化
     * @return
     */
    public QuantumEnergy getLastQuantumEnergy() {
        try {
            String data = hbaseBaseQueryComponent.selectByQualifierData(HbaseTableUtils.DAILY_QUANTUM_ENERGY_INFO_TABLE_NAME
                    , HbaseTableUtils.DAILY_QUANTUM_ENERGY_INFO_TABLE_FAMILY
                    , HbaseTableUtils.DAILY_QUANTUM_ENERGY_INFO_QUALIFIER
                    , DateUtils.getCurrentDateString());
            JSONObject mainObject;
            if(StringUtils.isBlank(data)){
                return null;
            }else{
                mainObject = JSON.parseObject(data);
            }
            for (int i = 0; i < LocalDateTime.now().getHour(); i++) {
                String key = String.valueOf(i);
                JSONArray jsonArray = mainObject.getJSONArray(key);
                QuantumEnergy quantumEnergy = null;
                if(CollectionUtil.isNotBlank(jsonArray)){
                    quantumEnergy = jsonArray.getObject(jsonArray.size()-1,QuantumEnergy.class);
                }
                if(quantumEnergy!=null){
                    return quantumEnergy;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            LogTrace.error(e.getMessage(),e);
        }
        return null;
    }


    /**
     * 获取涨跌
     * @return
     */
    public CurrentcyHighOrLow getCurrentcyHighOrLow() {

        try {
            String data = hbaseBaseQueryComponent.selectByQualifierData(HbaseTableUtils.DAILY_CHANGE_STATISTICS_INFO_TABLE_NAME
                    , HbaseTableUtils.DAILY_CHANGE_STATISTICS_INFO_TABLE_FAMILY
                    , HbaseTableUtils.DAILY_CHANGE_STATISTICS_INFO_TABLE_QUALIFIER
                    , DateUtils.getCurrentDateString());
            JSONObject mainObject;
            if(StringUtils.isBlank(data)){
                return null;
            }else{
                mainObject = JSON.parseObject(data);
            }
            for (int i = 0; i < LocalDateTime.now().getHour(); i++) {
                String key = String.valueOf(i);
                JSONArray jsonArray = mainObject.getJSONArray(key);
                CurrentcyHighOrLow currentcyHighOrLow = null;
                if(CollectionUtil.isNotBlank(jsonArray)){
                    currentcyHighOrLow = jsonArray.getObject(jsonArray.size()-1,CurrentcyHighOrLow.class);
                }
                if(currentcyHighOrLow!=null){
                    return currentcyHighOrLow;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            LogTrace.error(e.getMessage(),e);
        }
        return null;
    }

    public void saveConceptualQuotesDetail(ConceptCategory conceptCategory, List<CmcCurrencyInfo> lastCmcInfos) {
        try {
            this.insertHbaseString(HbaseTableUtils.CONCEPTUAL_QUOTES_DETAIL_TABLE_NAME
                    ,conceptCategory.getId()+"@"+DateUtils.getCurrentDateString()
                    ,HbaseTableUtils.CONCEPTUAL_QUOTES_DETAIL_TABLE_NAME_FAMILY
                    ,HbaseTableUtils.CONCEPTUAL_QUOTES_DETAIL_QUALIFIER
                    ,JSON.toJSONString(lastCmcInfos));
        } catch (Exception e) {
            e.printStackTrace();
            LogTrace.error(e.getMessage(),e);
        }
    }

    /**
     * 保存人气意愿
     * @param popularityIndicatorMap
     */
    public void savePopularityIndicator(Map<String, PopularityIndicator> popularityIndicatorMap) {
        for (String key:popularityIndicatorMap.keySet()) {
            PopularityIndicator popularityIndicator = popularityIndicatorMap.get(key);
            try {
                /*currencyInfoHbaseComponent.insertHbaseString(HbaseTableUtils.POPULARITY_INDICATOR_INFO_TABLE_NAME
                        ,DateUtils.getCurrentDateString()
                        ,HbaseTableUtils.POPULARITY_INDICATOR_INFO_TABLE_FAMILY
                        ,HbaseTableUtils.POPULARITY_INDICATOR_INFO_QUALIFIER
                        ,JSON.toJSONString(popularityIndicatorMap));*/
                Date createTime = popularityIndicator.getCreateTime();
                LocalDateTime dateTime = DateUtils.dateToLocalDateTime(createTime);
                String data = hbaseBaseQueryComponent.selectByQualifierData(HbaseTableUtils.POPULARITY_INDICATOR_INFO_TABLE_NAME
                        , HbaseTableUtils.POPULARITY_INDICATOR_INFO_TABLE_FAMILY
                        , HbaseTableUtils.POPULARITY_INDICATOR_INFO_QUALIFIER
                        , popularityIndicator.getId()+"@"+DateUtils.dateFormatString(createTime,DateUtils.format_ymds));
                JSONObject mainObject;
                if(StringUtils.isBlank(data)){
                    mainObject = new JSONObject();
                }else{
                    mainObject = JSON.parseObject(data);
                }
                mainObject.put(dateTime.getHour()+"",popularityIndicator);
                this.insertHbaseString(HbaseTableUtils.POPULARITY_INDICATOR_INFO_TABLE_NAME
                        ,popularityIndicator.getId()+"@"+DateUtils.dateFormatString(createTime,DateUtils.format_ymds)
                        ,HbaseTableUtils.POPULARITY_INDICATOR_INFO_TABLE_FAMILY
                        ,HbaseTableUtils.POPULARITY_INDICATOR_INFO_QUALIFIER
                        ,mainObject.toJSONString());
            } catch (HbaseConnectionExcetion | HbaseCloseExcetion | IOException | HbaseGetTableExcetion e) {
                e.printStackTrace();
                LogTrace.error(e.getMessage(),e);
            }
        }
    }

    public void saveMoneyEffect(MoneyEffect moneyEffect) {
        try {
            /*this.insertPerformance(HbaseTableUtils.DAILY_MONEY_EFFECT_INFO_TABLE_NAME
                    ,DateUtils.getCurrentDateString()
                    ,HbaseTableUtils.DAILY_MONEY_EFFECT_INFO_TABLE_FAMILY
                    ,HbaseTableUtils.DAILY_MONEY_EFFECT_INFO_TABLE_QUALIFIER
                    ,moneyEffect);*/
            Date createTime = moneyEffect.getCreateTime();
            LocalDateTime dateTime = DateUtils.dateToLocalDateTime(createTime);
            String data = hbaseBaseQueryComponent.selectByQualifierData(HbaseTableUtils.DAILY_MONEY_EFFECT_INFO_TABLE_NAME
                    , HbaseTableUtils.DAILY_MONEY_EFFECT_INFO_TABLE_FAMILY
                    , HbaseTableUtils.DAILY_MONEY_EFFECT_INFO_TABLE_QUALIFIER
                    , DateUtils.dateFormatString(createTime,DateUtils.format_ymds));
            JSONObject mainObject;
            if(StringUtils.isBlank(data)){
                mainObject = new JSONObject();
            }else{
                mainObject = JSON.parseObject(data);
            }
            String key = DateUtils.dateToLocalDateTime(createTime).getHour()+"";
            JSONArray jsonArray = mainObject.getJSONArray(key);
            if(jsonArray==null){
                jsonArray = new JSONArray();
            }
            jsonArray.add(moneyEffect);
            mainObject.put(key,jsonArray);
            this.insertHbaseString(HbaseTableUtils.DAILY_MONEY_EFFECT_INFO_TABLE_NAME
                    ,DateUtils.dateFormatString(createTime,DateUtils.format_ymds)
                    ,HbaseTableUtils.DAILY_MONEY_EFFECT_INFO_TABLE_FAMILY
                    ,HbaseTableUtils.DAILY_MONEY_EFFECT_INFO_TABLE_QUALIFIER
                    ,mainObject.toJSONString());
        } catch (HbaseConnectionExcetion | HbaseCloseExcetion | IOException | HbaseGetTableExcetion e) {
            e.printStackTrace();
            LogTrace.error(e.getMessage(),e);
        }
    }
}
